//
//  rootViewController.swift
//  阿恺微博
//
//  Created by 孙嘉恺 on 16/10/6.
//  Copyright © 2016年 孙嘉恺. All rights reserved.
//

import UIKit

class rootViewController: UIViewController {

    //懒加载属性, 只会创建一次
    var visitorView: VisitorView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = UIColor.white
        setupUI()
    }
}


extension rootViewController {
    func setupUI () {
        setupVisitorView()
    }
    
    func setupVisitorView () {
        if visitorView == nil {
            visitorView = VisitorView()
            //设置visitorview的代理
            visitorView?.delegate = self
            
            view.addSubview(visitorView!)
        }
    }
   
}
 //实现代理
extension rootViewController: VisitorViewDelegate {
    func loginClicked() {
        //modal弹出登录页面
        let oAuthViewController = OAuthViewController()
        let oAuthNav = UINavigationController(rootViewController: oAuthViewController)
        present(oAuthNav, animated: true, completion: nil)    }
}

